package com.xmall.controller.wx;

import com.xmall.bean.table.User;
import com.xmall.bean.vo.BaseRespVo;
import com.xmall.bean.vo.WxIndexOrderStatusVo;
import com.xmall.service.OrderService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController("wxUserController")
@RequestMapping("wx/user")
public class UserController {

    @Autowired
    OrderService orderService;

    @RequestMapping("index")
    public BaseRespVo index() {
        Subject subject = SecurityUtils.getSubject();
        User user = (User) subject.getPrincipal();
        Integer userId = user.getId();
        WxIndexOrderStatusVo orderStatusVo = orderService.queryOrderStatusByUserId(userId);
        return BaseRespVo.ok(orderStatusVo);
    }
}
